<script setup>
import {computed,onBeforeMount,ref} from "vue";
import nodeMixin from "../NodeMixin.js";
const props = defineProps({
  ...nodeMixin.props
})
const options=ref({
  unitId:[],
  nodeCategory: [//节点分类
    {
      label: '保前',
      value: '1',
    },
    {
      label: '保后',
      value: '2',
    },
  ],
})

const emit = defineEmits(nodeMixin.emits)
const _value = computed(nodeMixin.computed._value(props, emit))
const form=ref()
onBeforeMount(() => {


})
const fields=[
 {
    label: "固定时长",
    prop: 'timeLimit',
    placeholder: '请输入固定时长',
    type: 'input',
    unit:'天'
  },
  {
    label: "节点分类",
    prop: 'nodeCategory',
    placeholder: '请输入',
    type: 'radio',

  },
]
const rules={
  timeLimit: [
    { required: true, message: '请输入固定时长', trigger: 'change' },
    { min: 1, max: 3, message: '长度在1到3位的正整数', trigger: 'blur' },
    { pattern: /^[1-9]\d*$/, message: '请输入正确的固定时长' }
  ],
  nodeCategory: [
    { required: true, message: '请选择节点分类', trigger: 'change' },
  ],
}
function change(e){
}
function save(){
  form.value.verification().then(res=>{
    emit('close')
  })
}
</script>

<template>
  <div class="start">
    <div class="form_drawer">
      <myform :fields="fields" @change="change" ref="form" :model="_value.props" :rules="rules" labelPosition="top" :inline="false"
      :options="options">
    </myform>
    </div>
    <div class="d_f j_c_c">
        <el-button type="primary" @click="save" >保 存</el-button>
     </div>
  </div>

</template>

<style lang="scss">
.start{
  height: 100%;
  .el-input,
  .el-select {
    width: 100% !important;
  }
  .form_drawer{
    height: calc(100% - 70px);
    overflow-y: auto;
  }
}
</style>
